/*
 * file_notify.h
 *
 *  Created on: Feb 21, 2011
 *      Author: thienlong
 */

#ifndef FILE_NOTIFY_H_
#define FILE_NOTIFY_H_

#define FILE_NOTIFY_CAPACITY_DEFAULT 64
#include "stringbuffer.h"
#include "reuse_object.h"
#include "map.h"

typedef struct {
	stringbuffer *root_dir;
	int listener;
	stringbuffer **wd_dir;
	hashmap *dir_wd;
	int capacity;
	int flags;
	array_pool *pool;
} file_notify;

file_notify* file_notify_new(char *root, int flags, int is_recursive, array_pool *pool);
void file_notify_free(file_notify* notify);
int file_notify_add_watch(file_notify* notify, int wd, char *dirname, int flags);
int file_notify_add_watch_recursive(file_notify* notify, int wd, char *dirname,
		int flags);
int file_notify_add_watch_dirpath(file_notify* notify, char *dirpath, int flags);
int file_notify_add_watch_dirpath_reference(file_notify* notify,
		stringbuffer **dirpath, int flags);
int file_notify_add_watch_dirpath_recursive(file_notify* notify, char *dirpath, int flags);
int file_notify_replace_wath_dirname(file_notify* notify, int moved_wd, char* moved_dirname, int dst_wd, char* dst_dirname);
int file_notify_rm_watch(file_notify* notify, int wd);
int file_notify_rm_watch_dirpath(file_notify *notify, char *dirpath);
int file_notify_rm_watch_dirpath_recursive(file_notify *notify, char *dirpath);
int file_notify_rm_watch_dirname(file_notify *notify, int wd, char *dirname);
int file_notify_rm_watch_dirname_recursive(file_notify *notify, int wd, char *dirname);

#endif /* FILE_NOTIFY_H_ */
